import type { OrderStatusModel } from '@/pages/Order/data';

export const OrderTypeList = [
  {
    key: 0,
    code: 'unknown',
    name: '未知',
  },
  {
    key: 1,
    code: 'parking',
    name: '停车',
  },
  {
    key: 2,
    code: 'topup',
    name: '充值',
  },
];

export const OrderStatusList = [
  {
    key: 0,
    code: 'unknown',
    name: '未知',
  },
  {
    key: 1,
    code: 'paying',
    name: '待支付',
  },
  {
    key: 2,
    code: 'paid',
    name: '已支付',
  },
  {
    key: 3,
    code: 'close',
    name: '已关闭',
  },
  {
    key: 4,
    code: 'refund',
    name: '已退款',
  },
];

export const OrderStatusParse = {
  parse: (key: number): OrderStatusModel => {
    const obj = OrderStatusList.filter((o) => o.key === key)[0] || OrderStatusList[0];
    return {
      name: obj.name,
      key: obj.key,
      code: obj.code,
    };
  },
};

export const OrderTypeParse = {
  parse: (key: number) => OrderTypeList.filter((o) => o.key === key)[0] || OrderTypeList[0],
};
